<?php
class Call extends CI_Controller
{
    function __construct() {
        parent :: __construct();
        $this->load->helper('mail_helper');
        $this->load->model('call_model');

    }
    function thank() {
        $mesege = array();
        $st = $this->input->post('st');
        $phonec = $this->input->post('phonec');
        $phone = $this->input->post('phone');
        $phonecall = $this->input->post('phonecall');
        $from = $this->input->post('from');
        $from2 = $this->input->post('from2');
        $to = $this->input->post('to');
        $to2 = $this->input->post('to2');
        $national = $this->input->post('national');
        $data = array(
            'status'=>$st,
            'phonec'=>$phonec,
            'phone'=>$phone,
            'phonecall'=>$phonecall,
            'from'=>$from,
            'from2'=>$from2,
            'to'=>$to,
            'to2'=>$to2,
            'national'=>$national,
        );
        $ok1   = "";
        
        
        if($phone  == '' or $from  =='' or $to  =='' or $national  =='' or $phonecall== ''){
            $mesege[] = "<p style='color: red; font-size: 13px;'>Please enter the full information</p><br />";
        }
        else {
            $ok1 = TRUE;
        }

       
        if($ok1 == TRUE ) {
            $this->call_model->save($data);
            $this->sendmail($st, $phonec, $phone, $phonecall, $from, $from2, $to, $to2, $national);
            $html = "<h2 style='color: #dd1e43; text-align: center; font-size: 20px;'>Your message has been sent.</h2>";
            $html .= "<p style='text-align: center; margin-top: 25px; font-size: 12px; color: #4d4d4d;'>Warmest greetings from Bestcruiseshalong.com  -  Largest Halong Cruises’ Collection !</p>";
            $html .= "<p style='text-align: center; margin-top: 10px;font-size: 12px; color: #4d4d4d;'>
                Thank you for your enquiry. We are happy to answer any questions you may have and aim to respond within 24 hours or earlier possible.
            </p>";
            $html .= "<p style='text-align: center; margin-top: 25px;font-size: 12px; color: #4d4d4d;'>In the meantime, please feel free to contact us through our TOLL FREE: 1800 – 6368 for any urgent matter</p>";
            $html .= "<p style='text-align: center; margin-top: 25px;font-size: 12px; color: #4d4d4d;'>For special offers and packages please visit our website: http://bestcruiseshalong.com/home/news/all</p>";
            $html .= "<p style='text-align: center; margin-top: 30px;font-size: 12px; color: #4d4d4d;'>Bestcruiseshalong.com Team.</p>";
            $return = array(
                'status' => true,
                'sucsec' => $html,

            );
            echo json_encode($return);
        }else {
            $html = "<p style='color: red; font-size: 13px;'>Please input sufficent and correct information!</p><br />";
            $return = array(
                'erro' => $html,
            );
            echo json_encode($return);
        }

    }
    function sendmail($st, $phonec, $phone, $phonecall, $from, $from2, $to, $to2, $national)
    {
        //go noi dung theo mau thu A3
        $mesnger = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                <html>
                <head>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                </head>
                <body>
                 HAVE US CALL YOU!
                <br/>
                <br/>
        ';
        $mesnger .= 'Choose the option below that best describe your status : ' . $st . ' <br/>';
        $mesnger .= 'Phone: '. $phonec . '  - ' . $phone . '<br/>
            Time to receive our phonecall<br/> ';
        $mesnger .= 'Date : '. $phonecall .' <br/>';
        $mesnger .= 'Local time : from '. $from .'
        '.$from2.' to '. $to .'
        '. $to2 .'<br/>';
        $mesnger .= 'Country : '.$national.'<br/><br/><br/>';

        $mesnger .= 'IP address: '. $_SERVER['REMOTE_ADDR'] .' ;
        <br/>
        ';
        $mesnger .= '</body>
        </html> ';
        send_mail_helper('info@bestcruiseshalong.com', 'call', $mesnger);
    }
}
?>